package org.wanda.pv.model.hy;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.codehaus.jackson.map.Serializers;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;
import org.wanda.pv.framework.base.BaseModel;
import org.wanda.pv.model.basic.Specialty;
import org.wanda.pv.model.business.Mark;


import java.io.Serializable;
import java.util.List;

@Table("hy_drawing")
public class HyDrawing extends BaseModel implements Serializable {

    @Column
    @Id
    @Prev(els = {@EL("$me.idGen()")})
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;


    @Column("flow_map_model_id")
    private String flowMapModelId;

    @Column("project_flow_children_node_id")
    private String projectFlowChildrenNodeId;


    @Column("file_name")
    private String fileName;

    @Column("file_id")
    private String fileId;

    @Column("file_path")
    private String filePath;

    @Comment("0是未初始化，1是初始化中，二是初始化完成")
    @Column
    private int status;

    @Column
    @JsonSerialize(using = ToStringSerializer.class)
    private Long tfid;
    @Column
    @JsonSerialize(using = ToStringSerializer.class)
    private Long pfid;

    @Column
    @JsonSerialize(using = ToStringSerializer.class)
    private Long fid;

    @Column("png_width")
    @Comment("png宽度")
    private int pngWidth;

    @Column("png_height")
    @Comment("png高度")
    private int pngHeight;

    @Column("opinion_count")
    private int opinionCount;

    @Many(field = "drawingId")
    private List<Mark> mark;


    @Column("hy_project_info_id")
    private String projectId;

    @Column
    @Default("1")
    private Integer version;

    @Column
    @Prev(els = {@EL("$me.initVersion()")})
    private Boolean latest = true;

    @Column("org_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long orgId;

    @One(field = "hyUserInfoId")
    private HyUserInfo hyUserInfo;

    @Column("hy_user_info_id")
    private Long hyUserInfoId;

    @One(field = "flowMapModelId")
    private HyTree hyTree;



    @Column
    @Comment("排序字段")
    @Prev({
            @SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM hy_drawing"),
            @SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM hy_drawing")
    })
    private Integer location;

    public boolean initVersion(){
        return true;
    }
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getFlowMapModelId() {
        return flowMapModelId;
    }

    public void setFlowMapModelId(String flowMapModelId) {
        this.flowMapModelId = flowMapModelId;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }


    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Long getFid() {
        return fid;
    }

    public void setFid(Long fid) {
        this.fid = fid;
    }

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public int getPngWidth() {
        return pngWidth;
    }

    public void setPngWidth(int pngWidth) {
        this.pngWidth = pngWidth;
    }

    public int getPngHeight() {
        return pngHeight;
    }

    public void setPngHeight(int pngHeight) {
        this.pngHeight = pngHeight;
    }

    public String getProjectFlowChildrenNodeId() {
        return projectFlowChildrenNodeId;
    }

    public void setProjectFlowChildrenNodeId(String projectFlowChildrenNodeId) {
        this.projectFlowChildrenNodeId = projectFlowChildrenNodeId;
    }

    public int getOpinionCount() {
        return opinionCount;
    }

    public void setOpinionCount(int opinionCount) {
        this.opinionCount = opinionCount;
    }

    public List<Mark> getMark() {
        return mark;
    }

    public void setMark(List<Mark> mark) {
        this.mark = mark;
    }

    public Long getTfid() {
        return tfid;
    }

    public void setTfid(Long tfid) {
        this.tfid = tfid;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Boolean getLatest() {
        return latest;
    }

    public void setLatest(Boolean latest) {
        this.latest = latest;
    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }



    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    public Long getPfid() {
        return pfid;
    }

    public void setPfid(Long pfid) {
        this.pfid = pfid;
    }


    public HyUserInfo getHyUserInfo() {
        return hyUserInfo;
    }

    public void setHyUserInfo(HyUserInfo hyUserInfo) {
        this.hyUserInfo = hyUserInfo;
    }

    public Long getHyUserInfoId() {
        return hyUserInfoId;
    }

    public void setHyUserInfoId(Long hyUserInfoId) {
        this.hyUserInfoId = hyUserInfoId;
    }

    public HyTree getHyTree() {
        return hyTree;
    }

    public void setHyTree(HyTree hyTree) {
        this.hyTree = hyTree;
    }

    public Integer getLocation() {
        return location;
    }

    public void setLocation(Integer location) {
        this.location = location;
    }
}
